import {JSEncrypt} from 'jsencrypt';

// 加密
export const encryptedData = function(data) {
    //公钥和私钥和后端沟通是固定的
    let publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDIrboon2HHbV5+cbBBmnW/mok0kfD41AsZ2PS/6RrFQ4DZ7cWhcU+4KQLDxCBnODfjVOyCu2yLBy9MYC8pzahL3FOSW48GX3HHtYhlnT0lZiflPxvLEV9NEBQID+2fPFuUKNXeBtUipmH6aad1rRXOPKmk2EcBEcFwsDyy4j5crQIDAQAB";
    // 新建JSEncrypt对象

    let encryptor = new JSEncrypt();
    // 设置公钥
    encryptor.setPublicKey(publicKey);
    // 加密数据
    return encryptor.encrypt(data);
}